// Package sys
// @Link  https://github.com/bufanyun/hotgo
// @Copyright  Copyright (c) 2025 HotGo CLI
// @Author  Ms <133814250@qq.com>
// @License  https://github.com/bufanyun/hotgo/blob/master/LICENSE
// @AutoGenerate Version 2.15.11
package sys

import (
	"context"
	"hotgo/api/admin/store"
	"hotgo/internal/model/input/sysin"
	"hotgo/internal/service"
)

var (
	Store = cStore{}
)

type cStore struct{}

// List 查看门店管理列表
func (c *cStore) List(ctx context.Context, req *store.ListReq) (res *store.ListRes, err error) {
	list, totalCount, err := service.SysStore().List(ctx, &req.StoreListInp)
	if err != nil {
		return
	}

	if list == nil {
		list = []*sysin.StoreListModel{}
	}

	res = new(store.ListRes)
	res.List = list
	res.PageRes.Pack(req, totalCount)
	return
}

// Edit 更新门店管理
func (c *cStore) Edit(ctx context.Context, req *store.EditReq) (res *store.EditRes, err error) {
	err = service.SysStore().Edit(ctx, &req.StoreEditInp)
	return
}

// View 获取指定门店管理信息
func (c *cStore) View(ctx context.Context, req *store.ViewReq) (res *store.ViewRes, err error) {
	data, err := service.SysStore().View(ctx, &req.StoreViewInp)
	if err != nil {
		return
	}

	res = new(store.ViewRes)
	res.StoreViewModel = data
	return
}

// Delete 删除门店管理
func (c *cStore) Delete(ctx context.Context, req *store.DeleteReq) (res *store.DeleteRes, err error) {
	err = service.SysStore().Delete(ctx, &req.StoreDeleteInp)
	return
}
